In [ ]:
import numpy as np
import pandas as pd

In [ ]:
wine = pd.read_csv("../wine/winequality-red.csv")

In [ ]:
wine.head()

In [ ]:
wine.loc[wine.quality > 5, 'category'] = 1
wine.loc[wine.quality <= 5, 'category'] = 0

In [ ]:
wine.drop("quality", axis=1, inplace=True)

In [ ]:
from sklearn import tree

In [ ]:
wineTree = tree.DecisionTreeClassifier()

In [ ]:


In [ ]:
wineTree.fit(wine.iloc[:,[10]], wine.category)

In [ ]:
from sklearn import tree
from sklearn.externals.six import StringIO
import pydot

In [ ]:
dot_data = StringIO() 
tree.export_graphviz(wineTree, out_file=dot_data) 
graph = pydot.graph_from_dot_data(dot_data.getvalue()) 
graph.write_pdf("wine.pdf")

Exercise 1 Use the top two correlated features to build the decision tree. Visualize it.


In [ ]: